<template>
  <div class="datail">
    <h3>{{NewDatail.title}}</h3>
    <div class="info">
      <span>发表时间：{{(NewDatail.add_time|| '').split('T')[0]}}</span>
      <span>点击次数：{{NewDatail.click}}</span>
    </div>
    <div v-html="NewDatail.content"></div>
    <comment></comment>
  </div>
</template>

<script>
import comment from '../../components/comment.vue'
export default {
  data() {
    return {
      NewDatail: {}
    }
  },
  created() {
    this.getNewDatail()
  },
  methods: {
    async getNewDatail() {
      const id = this.$route.params.id
      const { data: res } = await this.$http.get(`/api/getnew/${id}`)
      if (res.status !== 0) {
        return this.$toast.fail('获取新闻详情失败！')
      }
      this.NewDatail = res.message[0]
    }
  },
  components: {
    comment
  }
}
</script>

<style lang="less" scoped>
h3 {
  color: #1989fa;
  font-size: 14px;
  text-align: center;
  line-height: 30px;
  margin: 0;
  padding: 5px 0;
}
.info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #1989fa;
  border-bottom: 1px solid #ccc;
  padding: 7px 0;
}
</style>
